package com.yricky.fakenote;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.IBinder;

import androidx.annotation.Nullable;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

public class GhostService extends Service {
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Intent nfIntent = new Intent(this,HelpActivity.class);
        NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);//新建NotificationManager用于管理Notification，设置Channel
        NotificationChannel mChannel = new NotificationChannel("mpfn", "ghost_service", NotificationManager.IMPORTANCE_HIGH);//新建NotificationChannel对象，参数分别为ChannelId、ChannelName和优先级
        manager.createNotificationChannel(mChannel);
        Notification.Builder builder = new Notification.Builder(this,"mpfn");
        Notification notification=builder.setContentIntent(PendingIntent.getActivity(this,0,nfIntent,0))
                .setContentTitle (getString(R.string.package_name) + getPackageName())
                .setContentText(getString(R.string.tap_to_detail))
                .setSmallIcon (R.mipmap.ic_launcher)
                .setWhen(System.currentTimeMillis()).build();
        startForeground(110,notification);
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onCreate() {
        super.onCreate();

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
